package com.zsrt.oa.user.dao.impl;

import java.lang.reflect.Field;
import java.lang.reflect.Method;

import org.junit.Test;

public class Reject {

	@Test
	public void test() throws Exception {
        
        Class<?> clazz = Class.forName("com.zsrt.oa.user.entity.UserEntity");
        
        //1.获取所有属性
        Field[]	field = clazz.getDeclaredFields();
        for(int index = 0; index <field.length; index++){
        	String name = field[index].getName();
        	System.out.println(name);
        }
        System.out.println("--------------------");
        
        //2.获取所有方法
        Method[] methods = clazz.getDeclaredMethods();
        for(int index = 0 ; index < methods.length; index++){
        	String name = methods[index].getName();
//        	System.out.println(name);
        	
        	//获取所有的get方法
        	String reg = "get.*";
        	if(name.matches(reg)){
//        		System.out.println(name);
        		methods[index].invoke(clazz.newInstance());
        		System.out.println(index+"  ");
        	}
        }
        
//        // 调用 类中的reflect2方法
//        method = clazz.getMethod("reflect2", int.class, String.class);
//        method.invoke(clazz.newInstance(), 20, "张三");
	}
}
